package com.cuckoo.mall.thus.order.orderlist.paidorder;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bgn.baseframe.utils.BaseStringUtil;
import com.bgn.baseframe.utils.ToastUtil;
import com.bgn.baseframe.utils.UiUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cuckoo.mall.R;
import com.cuckoo.mall.javabean.Order;

import java.util.List;

/**
 * Created by Administrator on 2018/3/31.
 */

public class PaidOrderQiuckAdapter extends BaseQuickAdapter<Order, BaseViewHolder> {

    public PaidOrderQiuckAdapter(@Nullable List<Order> data) {
        super(R.layout.list_item_paid_order, data);

    }

    @Override
    protected void convert(final BaseViewHolder helper, final Order item) {
        handleRecycleView(helper, item);

        helper.addOnClickListener(R.id.tv_del);
        helper.setText(R.id.tv_order_num, item.getOrder_number());
        helper.setText(R.id.tv_state, item.getStatus());

//        String priceString = "";
//        priceString = item.getCurrency() + " " + BaseStringUtil.getPrioceFormatString(item.getPay_money());
//        helper.setText(R.id.tv_price, priceString);
    }

    private void handleRecycleView(final BaseViewHolder helper, final Order item) {
        if (item.getProduct_list() != null && item.getProduct_list().size() > 0) {
            RecyclerView recyclerView = helper.getView(R.id.recycle_view);
            recyclerView.setLayoutManager(new LinearLayoutManager(UiUtil.getContext(), LinearLayoutManager.VERTICAL, false));
            OrderListImageQiuckAdapter adapter = new OrderListImageQiuckAdapter(item.getProduct_list());
            recyclerView.setAdapter(adapter);
            adapter.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                    ARouter.getInstance().build("/mall/orderdetailActivity").withString("order_number", item.getOrder_number()).navigation();
                }
            });
        }
    }

}
